package com.blueocean_health.care.management.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.blueocean_health.care.management.domain.base.SysResult;
import com.blueocean_health.care.management.service.ModuleService;

/**
* 模块Controllerr
* @author huyanqiu
* @date 2018年3月23日 下午2:24:54
* @version 版本号：1.0
*/
@RestController
@RequestMapping("/module")
public class ModuleController {
	
	@Autowired
	private ModuleService moduleService; 
	
	/**
	 * 获得模块清单，当前用户所属组织有权限使用的模块 
	 * @return
	 */
	@RequestMapping("/list")
	public SysResult list(@RequestBody String jsonString) {
		JSONObject jsonObject =  JSONObject.parseObject(jsonString);
		// 类型：1.泰心端模块  2. 项目端模块
		Integer type = (Integer) jsonObject.get("type");
		Integer orgId = (Integer) jsonObject.get("orgId");
		if (type!=1 && type!=2) {
			return SysResult.error("参数非法");
		}
		return moduleService.list(type, orgId);
	}

}
